package guda.house.biz.form.rule;

import guda.house.biz.util.PriceUtil;
import guda.house.dal.dataobject.BankChargeRuleDO;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;


public class BankChargeRuleForm {

    @NotNull(message = "不能为空")
    private Long varId;
    @NotNull(message = "不能为空")
    private String maxValue;
    @NotNull(message = "不能为空")
    @Pattern(regexp = "[+]?(0.)(\\d{0,4})?", message = "最多4位数的小数")
    private String chargeUnit;
    @NotNull(message = "不能为空")
    private Integer ruleStatus;
    @NotNull(message = "不能为空")
    private Long villageId;
    private String maxFee;




    public Long getVillageId() {
        return villageId;
    }

    public void setVillageId(Long villageId) {
        this.villageId = villageId;
    }


    public BankChargeRuleDO toDO() {
        BankChargeRuleDO bankChargeRuleDO = new BankChargeRuleDO();
        bankChargeRuleDO.setVarId(varId);
        if(maxValue!=null) {
            bankChargeRuleDO.setMaxValue(PriceUtil.convertPriceYuan(maxValue).intValue());
        }
        bankChargeRuleDO.setRuleStatus(ruleStatus);
        bankChargeRuleDO.setChargeUnit(PriceUtil.convertFeeCharge(chargeUnit).intValue());
        bankChargeRuleDO.setVillageId(villageId);
        if(maxFee!=null) {
            bankChargeRuleDO.setMaxFee(PriceUtil.convertPriceYuan(maxFee).intValue());
        }
        return bankChargeRuleDO;
    }

    public Long getVarId() {
        return varId;
    }

    public void setVarId(Long varId) {
        this.varId = varId;
    }


    public String getMaxValue() {
        return maxValue;
    }

    public void setMaxValue(String maxValue) {
        this.maxValue = maxValue;
    }

    public String getMaxFee() {
        return maxFee;
    }

    public void setMaxFee(String maxFee) {
        this.maxFee = maxFee;
    }

    public String getChargeUnit() {
        return chargeUnit;
    }

    public void setChargeUnit(String chargeUnit) {
        this.chargeUnit = chargeUnit;
    }

    public Integer getRuleStatus() {
        return ruleStatus;
    }

    public void setRuleStatus(Integer ruleStatus) {
        this.ruleStatus = ruleStatus;
    }
}
